//
//  SRPageManager.m
//  SportRing
//
//  Created by mykoma on 14-4-12.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRPageManager.h"

@interface SRPageManager ()
{
    NSMutableDictionary * _navDict;
}

@end

@implementation SRPageManager

CWL_SYNTHESIZE_SINGLETON_FOR_CLASS_WITH_ACCESSOR(SRPageManager, sharedInstance);

- (id)init
{
    self = [super init];
    if (self) {
        _navDict = [NSMutableDictionary dictionary];
    }
    return self;
}

-(UINavigationController *)navigationController:(NSString *)className
{
    UINavigationController * nav = _navDict[className];
    if (nav == nil)
    {
        UIViewController * viewController = [[NSClassFromString(className) alloc] initWithNibName:className
                                                                                           bundle:nil];
        if (viewController == nil)
        {
            viewController = [[NSClassFromString(className) alloc] init];
        }
        nav = [[UINavigationController alloc] initWithRootViewController:viewController];
        _navDict[className] = nav;
    }
    return nav;
}

@end
